import axios from '@/libs/api.request'

// 发送验证码
export const sendSms = (mobile) => {
  return axios.request({
    url: 'User/sendSms',
    data: { mobile },
    method: 'post',
    noToken: true
  })
}
//验证手机号是否被注册
export const checkIsRegister = (mobile) =>{
  return axios.request({
    url:'User/checkIsRegister',
    data: { mobile },
    method:'post',
    noToken: true
  })
}

// 注册
export const register = ({ mobile, password, code}) => {
  const data = {
    mobile,
    password,
    code,
  }
  return axios.request({
    url: 'User/register',
    data,
    method: 'post',
    noToken: true
  })
}

// 登录
export const login = ({ mobile, password,loginType }) => {
  const data = {
    mobile, password,loginType
  }
  return axios.request({
    url: 'User/login',
    data,
    method: 'post',
    noToken: true
  })
}

// 登出
export const loginOut = () => {
  return axios.request({
    url: 'User/loginOut',
    method: 'post',
    noToken: true
  })
}

// 忘记密码
export const forgetPassword = ({ mobile, password, code }) => {
  const data = {
    mobile, password, code
  }
  return axios.request({
    url: 'User/forgetPassword',
    data,
    method: 'post',
    noToken: true
  })
}

// 修改姓名
export const editName = ({ cid, name }) => {
  const data = {
    cid, name
  }
  return axios.request({
    url: 'User/editName',
    data,
    method: 'post'
  })
}

// 修改密码
export const editPassword = ({ cid, password }) => {
  const data = {
    cid, password
  }
  return axios.request({
    url: 'User/editPassword',
    data,
    method: 'post'
  })
}


// 获取用户详情
export const getUserDetail = (cid) => {
  return axios.request({
    url: 'User/getUserDetail',
    data: {cid},
    method: 'post'
  })
}
//获取用户粉丝列表
export const getUserFans = (cid )=>{
  return axios.request({
    url: 'User/getUserFans',
    data: {cid},
    method: 'post'
  })
}
//关注和取消关注
export const editUserRelation =({cid ,toUserId})=>{
  const data={
    cid,
    toUserId,
  }
  return axios.request({
    url:'User/editUserRelation',
    data,
    method:'post'
  })
}
//获取用户收藏文章列表
export const getUserCollectArticleList =( cid ) =>{
  return axios.request({
    url:'User/getUserCollectArticleList',
    data:{cid},
    method:'post'
  })
}
//我的黑名单
export const getBlacklisted = ( toUserId ) =>{
  return axios.request({
    url:'User/getBlacklisted',
    data:{ toUserId },
    method:'post',
  })
}
//获取用户文章列表
export const getUserArticleList = (cid)=>{
  return axios.request({
    url:'User/getUserArticleList',
    data:{cid},
    method:'post',
  })
}
//获取点赞消息通知
export const getCollectMessage = (cid) =>{
  return axios.request({
    url:'ArticleMessage/getCollectMessage',
    data:{ cid },
    method:'post',
  })
}
//获取评论消息通知
export const getCommentMessage = (cid) =>{
  return axios.request({
    url:'ArticleMessage/getCommentMessage',
    data:{ cid },
    method:'post',
  })
}
//修改用户信息
export const editUserInfo = ({cid,nickname,avatar,sex})=>{
  const data={
    cid,
    nickname,
    avatar,
    sex
  }
  return axios.request({
    url:'user/editUserInfo',
    data,
    method:'post'
  })
}
//更新用户关系
export const updateUserRelation = ({cid,toUserId})=>{
  const data={
    cid,
    toUserId,
  }
  return axios.request({
    url:'user/updateUserRelation',
    data,
    method:'post'
  })
}
//拉黑
export const blacklisted = ({toUserId,cid})=>{
  const data={
    toUserId,
    cid,
  }
  return axios.request({
    url:'user/blacklisted',
    data,
    method:'post'
  })
}
//店铺认证
export const commitShopVerify = ({cid,shopName,saleType,shopType,idCardPic1,idCardPic2,shopPics,businessLicencePic,businessLicenceNum,smokeLicencePic,foodLicencePic,latitude,longitude})=>{
  const data={
    cid,shopName,saleType,shopType,idCardPic1,idCardPic2,shopPics,businessLicencePic,businessLicenceNum,
    smokeLicencePic,foodLicencePic,latitude,longitude
  }
  return axios.request({
    url:'user/commitShopVerify',
    data,
    method:'post'
  })
}

